﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "GcmpUiPlatformFamily.h"
#include "GnufActionBase.h"
#include "GnufINotificationCenterEventHandler.h"
#include "GnufCheckGroupControl.h"

namespace gnuf
{
    class ValueInputSet;
    class ValueInputBase;
}

namespace gfam
{
    class GCMP_UI_PLATFORM_FAMILY_EXPORT GnufActionBaseWithDynamicPanel : public GnufActionBase, public gnuf::INotificationCenterEventHandler
    {
    public:
        GnufActionBaseWithDynamicPanel();
        virtual ~GnufActionBaseWithDynamicPanel();

    public:
        // 继承自INotificationCenterEventHandler
    public:
        virtual void onEvent(gnuf::INotificationCenterEventArgs*) override;
    protected:
        bool InitDynamicPanel();
        virtual bool InitDynamicPanelItems();
        virtual std::wstring GetDynamicPanelCaption();

        virtual void OnPostProcess();

        virtual void SetTextValueEnable(); // wangbh-a-gnuf

    public:
        typedef std::function<void(gnuf::ValueInputBase* pValueInputBase)> DynamicPanelItemProcessor;

        bool AddBoolValueInputGroup(std::uint16_t index,
            const std::wstring& groupName, const std::vector<std::wstring>& names, gnuf::ECheckGroupStyle groupStyle,
            DynamicPanelItemProcessor processor, int defaultItem = 0, const std::vector<std::wstring>& icons = std::vector<std::wstring>(),
            bool readOnly = false);

        bool AddBoolValueInputGroup(std::uint16_t index,
            const std::wstring& groupName, const std::vector<std::wstring>& names, const std::vector<bool>& defaultStatus, 
            gnuf::ECheckGroupStyle groupStyle, DynamicPanelItemProcessor processor, const std::vector<std::wstring>& icons = std::vector<std::wstring>(),
            bool readOnly = false);

        bool AddListValueInput(std::uint16_t index,
            const std::wstring& listName, const std::vector<std::wstring>& itemNames,
            DynamicPanelItemProcessor processor, int defaultItemIndex = 0,
            bool readOnly = false);

        bool AddBoolValueInput(std::uint16_t index,
            const std::wstring& inputName, bool value, DynamicPanelItemProcessor processor,
            bool readOnly = false);

        bool AddTextValueInput(std::uint16_t index,
            const std::wstring& inputName, const std::wstring& textValue, DynamicPanelItemProcessor processor,
            bool readOnly = false);

        bool AddListWidgetInput(std::uint16_t index,
            const std::wstring& listName, const std::vector<std::wstring>& itemNames,
            DynamicPanelItemProcessor processor,
            bool readOnly = false);

        gnuf::ValueInputBase* GetValueInputBase(std::uint16_t index);

    private:
        std::map<std::uint16_t, DynamicPanelItemProcessor> m_dynamicPanelItems;
        gcmp::OwnerPtr<gnuf::ValueInputSet> m_opValueInputSet;
    };
}

